package com.juku2024.juku.model

import android.os.Parcel
import android.os.Parcelable


class UpdateModel() : Parcelable {
    // 版本编号
    var versionCode: String? = null
    // 升级标题
    var title: String? = null
    // 升级说明内容
    var txt: String? = null
    // 按钮文本
    var btnTitle: String? = null
    // 网页url/apk地址
    var url: String? = null
    // 是否强制升级(是true 否false)
    var foreceUpdate = false
    // 是否apk包(是true 否false)
    var downloadApk = false
    // 版本号
    var versionNumber = 1
    var type = 0

    var msg: String? = null
    var success: String? = null

    constructor(parcel: Parcel) : this() {
        versionCode = parcel.readString()
        title = parcel.readString()
        txt = parcel.readString()
        btnTitle = parcel.readString()
        url = parcel.readString()
        foreceUpdate = parcel.readByte() != 0.toByte()
        downloadApk = parcel.readByte() != 0.toByte()
        versionNumber = parcel.readInt()
        type = parcel.readInt()
        msg = parcel.readString()
        success = parcel.readString()
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(versionCode)
        parcel.writeString(title)
        parcel.writeString(txt)
        parcel.writeString(btnTitle)
        parcel.writeString(url)
        parcel.writeByte(if (foreceUpdate) 1 else 0)
        parcel.writeByte(if (downloadApk) 1 else 0)
        parcel.writeInt(versionNumber)
        parcel.writeInt(type)
        parcel.writeString(msg)
        parcel.writeString(success)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<UpdateModel> {
        override fun createFromParcel(parcel: Parcel): UpdateModel {
            return UpdateModel(parcel)
        }

        override fun newArray(size: Int): Array<UpdateModel?> {
            return arrayOfNulls(size)
        }
    }
}